import 'package:direct_link/direct_link.dart';
import 'package:flutter/material.dart';
import 'package:syncfusion_flutter_charts/charts.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

final textStyle = TextStyle(color: Color.fromRGBO(255, 255, 255, 1),decoration: TextDecoration.none,fontSize: 15.sp);
class MaterialList extends StatefulWidget{

  Map dataMap;

  String title;

  // MaterialList({Key? key,required this.dataList,required this.title}):super(key: key);
  MaterialList({Key? key,required this.dataMap,required this.title}):super(key: key);
  @override
  _MaterialListState createState() => _MaterialListState();

}

class _MaterialListState extends State<MaterialList>{

  final TextStyle titleStyle = TextStyle(fontSize: 36.sp,color: Colors.white,height:2,letterSpacing:20.sp);
  final TextStyle textStyle = TextStyle(fontSize: 22.sp,color: Colors.white);
  @override
  void initState() {
    // TODO: implement initState
    super.initState();
  }

  @override
  void didChangeDependencies() {
    // TODO: implement didChangeDependencies
    super.didChangeDependencies();
  }

  @override
  void dispose() {
    // TODO: implement dispose
    super.dispose();
  }

  Widget _textList(){
    List<Widget> list = [];
    for (var element in widget.dataMap['stockData']){
      list.add(Text('${element["name"]} ${element["total_value"]}元',style: textStyle,),);
    }
    return  Column(children:list);
  }

  @override
  Widget build(BuildContext context) {
    return Card(
        color: Colors.black12,
        shadowColor: Colors.black12,
        margin:  const EdgeInsets.all(10.0),
        clipBehavior: Clip.antiAlias,
        elevation: 1.0,
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Text(widget.title+widget.dataMap['totalPrice'].toString()+'元',style: titleStyle,),
            Expanded(child: _textList()),
          ],
        )
    );
  }

}

